<%@ page import="schoolsource.sql.SchoolDBSQL" %>
<%@ page import="schoolsource.gui.FormFields" %>
<%@ page import="schoolsource.model.UserContainer" %>
<%@ page import="schoolsource.model.SchoolContainer" %>
<%@ page import="schoolsource.model.Item" %>
<%@ page import="schoolsource.security.SecurityToken" %>
<%  
    SecurityToken st = (SecurityToken) request.getAttribute(FormFields.SESSION);
    String requestObject = (String) st.getValue(FormFields.TOKEN);
    UserContainer studentContainer = (UserContainer) st.removeValue("studentContainer"); 
    Item availableClassList[][] = (Item[][]) st.removeValue("availableClassList"); 
    Item assignedClassList[][] = (Item[][]) st.removeValue("assignedClassList"); 
//    Item assignedTeacherList[][] = (Item[][]) st.removeValue("assignedTeacherList");
    Item assignedTeacherList[][][] = (Item[][][]) st.removeValue("assignedTeacherList");
    Item availableParentList[][] = (Item[][]) st.removeValue("availableParentList");
    Item assignedParentList[][] = (Item[][]) st.removeValue("assignedParentList");
    String editStatus = (String) st.removeValue(FormFields.EDITSTATUS);
    int editorPage = (new Integer((String) st.getValue(FormFields.EDITORPAGE))).intValue();

//    int editorPage = -1;
//    if (FormFields.EDITOR.equals(st.getValue(FormFields.USRTYPE))) {
//      editorPage = (new Integer((String) st.getValue(FormFields.EDITORPAGE))).intValue();
//    }
    String displayMessage = (String) st.getValue("displayMessage"); 
    st.putValue("displayMessage", "");
    String loginType = (String) request.getAttribute(FormFields.USRTYPE); 
    String schoolName = (String) request.getAttribute(FormFields.SCHOOLNAME);
    String studentPicture = studentContainer.getPictureName().toString();
%> 



<HTML>

<HEAD>

  <title>Student Editor Form</title>

    <SCRIPT LANGUAGE="JavaScript">
        var availableClassArray = new Array();
        var assignedClassArray = new Array();
        var availableParentArray = new Array();
        var assignedParentArray = new Array();
        var d = top.frames.viewframe.document;
        var padding = "&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp";
    
        function validateRequiredFields() {
            if (document.forms[0].<%= SchoolDBSQL.USRSCHOOLID %>.value == "") {
                alert("You must enter an ID for the student.");
                document.forms[0].<%= SchoolDBSQL.USRSCHOOLID %>.focus();
                return false;
            }
            else {
                return true;
            }
        }
        
        function validateNewPasswords() {
        
            var newPassword1 = document.forms[0].<%= SchoolDBSQL.USRPASSWORD %>.value;
            var newPassword2 = document.forms[0].<%= SchoolDBSQL.USRPASSWORD %>2.value;
            var userID = document.forms[0].<%= SchoolDBSQL.USRASSIGNEDID %>.value;
            
            if (newPassword1 == "") {
                if (userID == -1) {
                    alert("You must enter a password.");
                    document.forms[0].<%= SchoolDBSQL.USRPASSWORD %>.focus();
                    return false;
                }
                else if (confirm("You did not specify a password. Leave existing password unchanged?")) {
//          if (newPassword1 == "") {
//              if (confirm("You did not specify a password. Leave existing password unchanged?")) {
                    return true;
                }
                else {
                    document.forms[0].<%= SchoolDBSQL.USRPASSWORD %>.focus();
                    return false;
                }
            }
            else if (newPassword1 != newPassword2) {
                alert("The new passwords you entered do not match.\nPlease re-enter your new password in both fields.");
                document.forms[0].<%= SchoolDBSQL.USRPASSWORD %>.focus();
                return false;
            }
            else {
                return true;
            }
        }
    
        function postProcessing(x) {
            if (validateRequiredFields() && validateNewPasswords()) {
                document.forms[0].<%= FormFields.SAVESTUDENT %>.value = x;
            buildStrings();
            document.forms[0].submit();
            }
        }
    
        function init() { 
            <% 
                if (!editStatus.equals(FormFields.VIEW)) {
                    for (int i = 0; i < availableClassList.length; i++) {
                        out.println("insertOptionIntoArray(availableClassArray, \"" + availableClassList[i][0].toString() + "\", \"" + availableClassList[i][1].toString()+"\", \"" + availableClassList[i][2].toString() + "\");");
                        out.println("insertOptionIntoList(d.forms[0].availableClassList, \"" + availableClassList[i][0] + "\", \"" + availableClassList[i][1] + " " + availableClassList[i][2] + "\");");
                    }
                    for (int i = 0; assignedClassList != null && i < assignedClassList.length; i++) {
                        out.println("insertOptionIntoArray(assignedClassArray, \"" + assignedClassList[i][0].toString() + "\", \"" + assignedClassList[i][1].toString() + "\", \"" + assignedClassList[i][2].toString() + "\");");
                        out.println("insertOptionIntoList(d.forms[0].assignedClassList, \"" + assignedClassList[i][0] + "\", \"" + assignedClassList[i][1] + " " + assignedClassList[i][2] + "\");");
                        out.println("removeOptionFromArray(availableClassArray, \"" + assignedClassList[i][0].toString() + "\");");
                        out.println("removeOptionFromList(d.forms[0].availableClassList, \"" + assignedClassList[i][0].toString() + "\");");
                    }
                    for (int i = 0; i < availableParentList.length; i++) {
                        out.println("insertOptionIntoArray(availableParentArray, \"" + availableParentList[i][0].toString() + "\", \"" + availableParentList[i][1].toString()+"\", \"" + availableParentList[i][2].toString() + "\");");
                        out.println("insertOptionIntoList(d.forms[0].availableParentList, \"" + availableParentList[i][0] + "\", \"" + availableParentList[i][2] + ", " + availableParentList[i][1] + "\");");
                    }
                    for (int i = 0; assignedParentList != null && i < assignedParentList.length; i++) {
                        out.println("insertOptionIntoArray(assignedParentArray, \"" + assignedParentList[i][0].toString() + "\", \"" + assignedParentList[i][1].toString() + "\", \"" + assignedParentList[i][2].toString() + "\");");
                        out.println("insertOptionIntoList(d.forms[0].assignedParentList, \"" + assignedParentList[i][0] + "\", \"" + assignedParentList[i][2] + ", " + assignedParentList[i][1] + "\");");
                        out.println("removeOptionFromArray(availableParentArray, \"" + assignedParentList[i][0].toString() + "\");");
                        out.println("removeOptionFromList(d.forms[0].availableParentList, \"" + assignedParentList[i][0].toString() + "\");");
                    }
                }
            %>
            if ("<%= displayMessage %>" != "null" && "<%= displayMessage %>" != "") {
              top.frames.mainframe.notify("<%= displayMessage %>");
            }
        }

        function viewDetailedInfo(page, selectedItem) {
            top.frames.mainframe.document.forms[0].<%= FormFields.SUBLINK %>.value = selectedItem;
            top.frames.mainframe.submitPage(top.frames.mainframe.document, "<%= FormFields.EDITORPAGE %>", page);
            return false;
        }
        
        function viewProgressReport(classAssignedID, studentAssignedID) {
            top.frames.viewframe.document.forms.studenteditorform.<%= FormFields.STUDENTID %>.value = studentAssignedID;
            top.frames.viewframe.document.forms.studenteditorform.<%= FormFields.CLASSNUM %>.value = classAssignedID;
            top.frames.viewframe.document.forms.studenteditorform.<%= FormFields.LINKCLICKED %>.value = "<%= FormFields.PROGRESSLINK %>";
            top.frames.viewframe.document.forms.studenteditorform.<%= FormFields.PARAMETER %>.value = "";
            top.frames.viewframe.document.forms.studenteditorform.submit();
            return false;
        }

        function existsInArray(anArray, key) {
            for (var i in anArray) {
                if (anArray[i][0] == key) {
                    return true;
                }
            }
            
            return false;
        }
        
        function existsInList(aList, key) {
            for (var i = 0; i < aList.length; i++) {
                if (aList[i].value == key) {
                    return true;
                }
            }
            
            return false;
        }

        function insertOptionIntoArray(anArray, avalue, bvalue, cvalue) {
            if (!existsInArray(anArray, avalue)) {
                anArray[anArray.length] = new Array(3);
//                var newArray = new Array();
//                newArray[0] = avalue;
//                newArray[1] = bvalue;
//                newArray[2] = cvalue;
                anArray[anArray.length-1][0] = avalue;
                anArray[anArray.length-1][1] = bvalue;
                anArray[anArray.length-1][2] = cvalue;
    
//                anArray.push(newArray);
            }
        }
        
        function insertOptionIntoList(selectList, value, text) {
            if (!existsInList(selectList, value)) {
                var o = new Option(text, value);
                var temp;
                for (var i = 0; i < selectList.length; i++) {
                    if (selectList[i].text > o.text) {
                        temp = selectList[i];
                        selectList[i] = o;
                        o = temp;
                    }
                }
                selectList[selectList.length]=o;
            }
        }
        
        function removeOptionFromArray(anArray, key) {
//            var tempArray;
//            var returnVal = null;
//            for (var i = 0; i < anArray.length; i++) {
//                if (anArray[i][0] == key) {
//                    returnVal = anArray.splice(i, 1)[0];
//                    return returnVal;
//                }
//            }
			var returnVal = null;
			for (var i = 0; i < anArray.length; i++) {
				if (anArray[i][0] == key) {
					returnVal = anArray[i];
					var j = i + 1;
					for (; j < anArray.length; j++, i++) {
						anArray[i] = anArray[j];
					}
					anArray[j] = null;
					anArray.length = j;
			
					return returnVal;
				}
			}
        }
        
        function removeOptionFromList(selectList, key) {
            var returnVal = null;
            for (var i = 0; i < selectList.length; i++) {
                if (selectList[i].value == key) {
                    returnVal = selectList[i];
                    selectList[i] = null;
                    return returnVal;
                }
            }
        }

        function selectAvailableParent() {
            var selectedValues = new Array();
            var w = top.frames.viewframe;
            var d = w.document;
            var availList = d.forms[0].availableParentList;
            var assgnList = d.forms[0].assignedParentList;
            var counter = 0;

            for (var i = 0; i < availList.length; i++) {
                var arrayTemp = null;
                var listTemp = null;
                if (availList[i].selected) {
                    arrayTemp = removeOptionFromArray(availableParentArray, availList[i].value);
                    insertOptionIntoArray(assignedParentArray, arrayTemp[0], arrayTemp[1], arrayTemp[2]);
                    listTemp = removeOptionFromList(availList, availList[i].value);
                    insertOptionIntoList(assgnList, listTemp.value, listTemp.text);
                    i--;
                }
            }
        }
        
        function unselectAssignedParent() {
            var selectedValues = new Array();
            var w = top.frames.viewframe;
            var d = w.document;
            var availList = d.forms[0].availableParentList;
            var assgnList = d.forms[0].assignedParentList;
            var counter = 0;

            for (var i = 0; i < assgnList.length; i++) {
                var arrayTemp = null;
                var listTemp = null;
                if (assgnList[i].selected) {
                    arrayTemp = removeOptionFromArray(assignedParentArray, assgnList[i].value);
                    insertOptionIntoArray(availableParentArray, arrayTemp[0], arrayTemp[1], arrayTemp[2]);
                    listTemp = removeOptionFromList(assgnList, assgnList[i].value);
                    insertOptionIntoList(availList, listTemp.value, listTemp.text);
                    i--;
                }
            }
        }
        
        function selectAvailableClass() {
            var selectedValues = new Array();
            var w = top.frames.viewframe;
            var d = w.document;
            var availList = d.forms[0].availableClassList;
            var assgnList = d.forms[0].assignedClassList;
            var counter = 0;

            for (var i = 0; i < availList.length; i++) {
                var arrayTemp = null;
                var listTemp = null;
                if (availList[i].selected) {
                    arrayTemp = removeOptionFromArray(availableClassArray, availList[i].value);
                    insertOptionIntoArray(assignedClassArray, arrayTemp[0], arrayTemp[1], arrayTemp[2]);
                    listTemp = removeOptionFromList(availList, availList[i].value);
                    insertOptionIntoList(assgnList, listTemp.value, listTemp.text);
                    i--;
                }
            }
        }
        
        function unselectAssignedClass() {
            var selectedValues = new Array();
            var w = top.frames.viewframe;
            var d = w.document;
            var availList = d.forms[0].availableClassList;
            var assgnList = d.forms[0].assignedClassList;
            var counter = 0;

            for (var i = 0; i < assgnList.length; i++) {
                var arrayTemp = null;
                var listTemp = null;
                if (assgnList[i].selected) {
                    arrayTemp = removeOptionFromArray(assignedClassArray, assgnList[i].value);
                    insertOptionIntoArray(availableClassArray, arrayTemp[0], arrayTemp[1], arrayTemp[2]);
                    listTemp = removeOptionFromList(assgnList, assgnList[i].value);
                    insertOptionIntoList(availList, listTemp.value, listTemp.text);
                    i--;
                }
            }
        }
                
        function buildStrings() {
            buildAssignedClassString();
            buildAssignedParentString();
        }
        
        function buildAssignedClassString() {
            var result = "";
            for (var i=0; i < assignedClassArray.length; i++) {
                if (i == 0) {
                    result = assignedClassArray[i][0];
                }
                else {
                    result = result + "," + assignedClassArray[i][0];
                }
            }
            document.forms["studenteditorform"].ASSIGNEDCLASSES.value = result;
            return true;
        }

        function buildAssignedParentString() {
            var result = "";
            for (var i=0; i < assignedParentArray.length; i++) {
                if (i == 0) {
                    result = assignedParentArray[i][0];
                }
                else {
                    result = result + "," + assignedParentArray[i][0];
                }
            }
            document.forms["studenteditorform"].ASSIGNEDPARENTS.value = result;
            return true;
        }

      // this doesn't seem to be used
      
      function refreshAvailableClassFrame(w) {
          var d = w.document;
          var pad;
          d.writeln("    <HTML><HEAD></HEAD>");
          d.writeln("");
          d.writeln("<BODY>\n");
          d.writeln("      <FORM NAME=\"availableClassForm\" METHOD=\"POST\" onSubmit=\"return false;\">\n");
          d.writeln("<SELECT NAME=\"availableClassList\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<availableClassArray.length; i++){
              if (availableClassArray[i][0] != null) {
                  if (availableClassArray.length < (padding.length/5)) {
                      pad = padding.substring(5 * (availableClassArray[i][1].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + availableClassArray[i][0] + "\">" + availableClassArray[i][1] + " " + availableClassArray[i][2]  + pad + "</OPTION>\n");
              }
          }
          if (availableClassArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.writeln("</SELECT>\n");
          d.writeln("      </FORM>\n");
          d.writeln("    </BODY></HTML>\n");
          d.close();
        }

        function refreshAvailableParentFrame(w) {
          var d = w.document;
          var pad;
          d.writeln("    <HTML><HEAD></HEAD>");
          d.writeln("");
          d.writeln("<BODY>\n");
          d.writeln("      <FORM NAME=\"availableParentForm\" METHOD=\"POST\" onSubmit=\"return false;\">\n");
          d.writeln("<SELECT NAME=\"availableParentList\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<availableParentArray.length; i++){
              if (availableParentArray[i][0] != null) {
                  if (availableParentArray.length < (padding.length/5)) {
                      pad = padding.substring(5 * (availableParentArray[i][1].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + availableParentArray[i][0] + "\">" + availableParentArray[i][1] + " " + availableParentArray[i][2]  + pad + "</OPTION>\n");
              }
          }
          if (availableParentArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.writeln("</SELECT>\n");
          d.writeln("      </FORM>\n");
          d.writeln("    </BODY></HTML>\n");
          d.close();
        }

        function refreshAssignedClassFrame(w) {
          var d = w.document;
          var pad;
          d.write("    <HTML><HEAD></HEAD><BODY>\n");
          d.write("      <FORM NAME=\"assignedClassForm\" METHOD=\"POST\" onSubmit=\"return false;\">\n");
          d.write("<SELECT NAME=\"assignedClassList\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<assignedClassArray.length; i++){
              if (assignedClassArray[i][0] != null) {
                  if (assignedClassArray[i][0].length < (padding.length/5)) {
                      pad = padding.substring(5 * (assignedClassArray[i][0].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + assignedClassArray[i][0] + "\">" + assignedClassArray[i][1] + assignedClassArray[i][2] + pad + "</OPTION>\n");
              }
          }
          if (assignedClassArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.write("</SELECT>\n");
          d.write("      </FORM>\n");
          d.write("    </BODY></HTML>\n");
          d.close();
        }

        function refreshAssignedParentFrame(w) {
          var d = w.document;
          var pad;
          d.write("    <HTML><HEAD></HEAD><BODY>\n");
          d.write("      <FORM NAME=\"assignedParentForm\" METHOD=\"POST\" onSubmit=\"return false;\">\n");
          d.write("<SELECT NAME=\"assignedParentList\" MULTIPLE=\"YES\" SIZE=\"5\">");
          for (var i=0; i<assignedParentArray.length; i++){
              if (assignedParentArray[i][0] != null) {
                  if (assignedParentArray[i][0].length < (padding.length/5)) {
                      pad = padding.substring(5 * (assignedParentArray[i][0].length), padding.length);
                  }
                  d.write("      <OPTION VALUE=\"" + assignedParentArray[i][0] + "\">" + assignedParentArray[i][1] + assignedParentArray[i][2] + pad + "</OPTION>\n");
              }
          }
          if (assignedParentArray.length == 0) {
              d.write("      <OPTION VALUE=\"\">" + padding + "</OPTION>\n");
          }
          d.write("</SELECT>\n");
          d.write("      </FORM>\n");
          d.write("    </BODY></HTML>\n");
          d.close();
        }

        function cancelForm() {
            document.forms[0].<%= FormFields.LINKCLICKED %>.value = "<%= FormFields.CANCEL %>";
            document.forms[0].submit();
        }
        
        function enableEdit() {
            var actionmenu = top.frames.mainframe.getNode(top.frames.menuframe.document.body.childNodes, "actionmenu");
            var editaction = top.frames.mainframe.getNode(top.frames.mainframe.getNode(actionmenu.childNodes, "editaction").childNodes, "<%= FormFields.EDITACTION %>");
            <% 
              SchoolContainer sc = SchoolContainer.getSchoolContainer(st.getValue(FormFields.SCHOOLNAME).toString());
          String activeLink = sc.getSchoolActiveLinkColor().toString();
        %>
            editaction.style.color = "<%= activeLink %>";

        }

    </SCRIPT>
  </HEAD>
  <BODY <% if (!editStatus.equals(FormFields.VIEW)) {
               out.print("onLoad=\"init()\"");
           }
           else if (studentContainer != null) {
               out.print("onLoad=\"top.frames.mainframe.highlightByID('" + studentContainer.getAssignedID() + "');\"");
           }
        %>>

    <FORM NAME="studenteditorform" METHOD="POST">
        <INPUT TYPE="HIDDEN" NAME="ASSIGNEDCLASSES" VALUE="">
        <INPUT TYPE="HIDDEN" NAME="ASSIGNEDPARENTS" VALUE="">
        <INPUT TYPE="HIDDEN" NAME="<%= SchoolDBSQL.USRASSIGNEDID %>" VALUE="<%= studentContainer.getAssignedID().toString() %>">
        <INPUT TYPE="HIDDEN" NAME="<%= SchoolDBSQL.USRTYPE %>" VALUE="<%= SchoolDBSQL.STUDENT %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CURRENT %>" VALUE="<%= FormFields.SUBFRAME %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.TOKEN %>" VALUE="<%= requestObject%>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.PARAMETER %>" VALUE="<%= FormFields.EDSTUDENTPAGE %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.LINKCLICKED %>" VALUE="<%= FormFields.SAVEACTION %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.EDITORPAGE %>" VALUE="<%= editorPage %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.SAVESTUDENT %>" VALUE=""> 
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.SCHOOLNAME %>" VALUE="<%= schoolName %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.USRTYPE %>" VALUE="<%= loginType %>">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.CLASSNUM %>" VALUE="">
        <INPUT TYPE="HIDDEN" NAME="<%= FormFields.STUDENTID %>" VALUE="">

            <TABLE style="font-size:12;font-family:sans-serif;">
                <TR>
                <TD colspan="2">
                    <H2>Student Editor</H2><br>
                </TD>
                </TR>
                <TR>
                <TH ALIGN="LEFT">Student ID</TH>
                <TD>
                <% if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("                <INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USRSCHOOLID + "\" VALUE=\"" + studentContainer.getSchoolID().toString() + "\">");
                  }
                  else {
                    out.println("                " + ((studentContainer!=null) ? studentContainer.getSchoolID().toString() : ""));
                  }
                %>
                </TD>
                <TD rowspan="5" colspan="2" ALIGN="CENTER">
                <%
                if (studentPicture != null && studentPicture.trim().length() != 0)
                    out.println("<IMG src=\"..\\attachments\\"+schoolName+"\\PICTURES\\"+ studentPicture +"\" width=\"100\">");
                else
                    out.println("<B>NO PHOTO<BR>AVAILABLE</B>");
               %>
                </TD>
            </TR>

            <TR>
                <TH ALIGN="LEFT">Title</TH>
                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("                <TD><INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USRTITLE + "\" VALUE=\"" + studentContainer.getTitle().toString() + "\"></TD>");
                  }
                  else {
                    out.println("                <TD>" + studentContainer.getTitle().toString() + "</TD>");
                  }
                %>
            </TR>

            <TR>
                <TH ALIGN="LEFT">First Name</TH>
                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("<TD><INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USRFNAME + "\" VALUE=\"" + studentContainer.getFirstName().toString() + "\"></TD>");
                  }
                  else {
                    out.println("<TD>" + studentContainer.getFirstName().toString() + "</TD>");
                  }
                %>
            </TR>

            <TR>
                <TH ALIGN="LEFT">Last Name</TH>
                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("                <TD><INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USRLNAME + "\" VALUE=\"" + studentContainer.getLastName().toString() + "\"></TD>");
                  }
                  else {
                    out.println("                <TD>" + studentContainer.getLastName().toString() + "</TD>");
                  }
                %>
            </TR>
            <TR>
                <TH ALIGN="LEFT">Phone Number</TH>
                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("                <TD><INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USRPHONE + "\" VALUE=\"" + studentContainer.getPhone().toString() + "\"></TD>");
                  }
                  else {
                    out.println("                <TD>" + studentContainer.getPhone().toString() + "</TD>");
                  }
                %>
            </TR>

            <TR>
                <TH ALIGN="LEFT">Email Address</TH>
                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("                <TD><INPUT TYPE=\"TEXT\" NAME=\"" + SchoolDBSQL.USREMAIL + "\" VALUE=\"" + studentContainer.getEmail().toString() + "\"></TD>");
                    out.println("                <TH>Add/Change Photo:&nbsp;&nbsp;</TH><TD COLSPAN=\"1\"><input type=\"file\" name=\"" + SchoolDBSQL.USRPICTURENAME + "\"  VALUE=\"\"></TD>");
                  }
                  else {
                    out.println("                <TD>" + studentContainer.getEmail().toString() + "</TD>");
                  }
                %>
            </TR>

                <%
                  if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                    out.println("            <TR>");
                    out.println("                <TH ALIGN=\"LEFT\">Password</TH>");
                    out.println("                <TD><INPUT TYPE=\"PASSWORD\" NAME=\"" + SchoolDBSQL.USRPASSWORD + "\" VALUE=\"\"></TD>");
                    out.println("                <TH ALIGN=\"LEFT\">Re-enter Password</TH>");
                    out.println("                <TD><INPUT TYPE=\"PASSWORD\" NAME=\"" + SchoolDBSQL.USRPASSWORD + "2\" VALUE=\"\"></TD>");
                    out.println("            </TR>");
                  }
                %>


                <%
                  if (editStatus.equals(FormFields.VIEW)) {
                    out.println("            <TR>");
                    out.println("                <TH ALIGN=\"LEFT\" VALIGN=\"TOP\">Parent(s)</TH>");
                    out.println("                <TD>");
                    for (int i = 0; i < assignedParentList.length; i++) {
                        out.print("<a href=\"\" onClick=\"viewDetailedInfo('" + FormFields.EDPARENTPAGE + "','" + assignedParentList[i][0] + "');return false;\">");
                        out.print(assignedParentList[i][2] + ", " + assignedParentList[i][1]);
                        out.print("</a>");
                        out.println("<br>");
                    }
                    out.println("                </TD>");
                    out.println("            </TR>");
                    out.println("            <TR>");
                    out.println("                <TD COLSPAN=2>&nbsp;</TD>");
                    out.println("                <TD COLSPAN=2>&nbsp;</TD>");
                    out.println("            </TR>");
                    out.println("            <TR>");
                    out.println("                <TH VALIGN=\"TOP\" ALIGN=\"LEFT\">Class list</TH>");
                    out.println("                <TD colspan=\"3\">");
                    out.println("                  <TABLE Width=\"100%\"style=\"font-size:11;font-family:sans-serif;\">");
                    out.println("                    <TR>");
                    out.println("                      <TH valign=\"bottom\" ALIGN=\"LEFT\" WIDTH=\"150\">Course</TH>");
                    out.println("                      <TH>&nbsp;&nbsp;&nbsp;</TH>");
                    out.println("                      <TH valign=\"bottom\" ALIGN=\"LEFT\" WIDTH=\"150\">Class</TH>");
                    out.println("                      <TH>&nbsp;&nbsp;&nbsp;</TH>");
                    out.println("                      <TH valign=\"bottom\" ALIGN=\"LEFT\" WIDTH=\"80\">Hour</TH>");
                    out.println("                      <TH>&nbsp;&nbsp;&nbsp;</TH>");
                    out.println("                      <TH valign=\"bottom\" ALIGN=\"LEFT\" WIDTH=\"100\">Teacher</TH>");
                    out.println("                      <TH>&nbsp;&nbsp;&nbsp;</TH>");
                    out.println("                      <TH ALIGN=\"LEFT\" WIDTH=\"20\">Progress Report</TH>");
                    out.println("                    </TR>");
                    for (int i = 0; i < assignedClassList.length; i++) {
                        out.println("                    <TR>");
                        out.print("<TD>");
                        out.print("<a href=\"\" onClick=\"viewDetailedInfo('" + FormFields.EDCLASSPAGE + "','" + assignedClassList[i][0] + "');return false;\">");
                        out.print(assignedClassList[i][3]);
                        out.print("</a>");
                        out.print("</TD><TD>&nbsp;</TD>\n<TD>");
                        out.print("<a href=\"\" onClick=\"viewDetailedInfo('" + FormFields.EDCLASSPAGE + "','" + assignedClassList[i][0] + "');return false;\">");
                        out.print(assignedClassList[i][1]);
                        out.print("</a>");
                        out.print("</TD><TD>&nbsp;</TD>\n<TD>");
                        out.print("<a href=\"\" onClick=\"viewDetailedInfo('" + FormFields.EDCLASSPAGE + "','" + assignedClassList[i][0] + "');return false;\">");
                        out.print(assignedClassList[i][2]);
                        out.print("</a>");
                        out.print("</TD>\n<TD>&nbsp;</TD>\n<TD>");
                        for (int j = 0; j < assignedTeacherList[i].length; j++) {
                            out.print("<a href=\"\" onClick=\"viewDetailedInfo('" + FormFields.EDTEACHERPAGE + "','" + assignedTeacherList[i][j][0] + "');return false;\">");
                            out.print(assignedTeacherList[i][j][2] + ", " + assignedTeacherList[i][j][1]);
                            out.print("<br></a>");
                        }
                        out.print("</TD><TD>&nbsp;</TD>\n<TD>");
                        out.print("<a href=\"\" onClick=\"viewProgressReport('" + assignedClassList[i][0] + "', '" + studentContainer.getAssignedID().toString() + "');return false;\">");
                        out.print("View");
                        out.print("</a></TD>");
                        out.println("                    </TR>");
                    }
                    out.println("                  </TABLE>");
                    out.println("                </TD>");
                    out.println("            </TR>");
                  }
                  else {
                    out.println("            <TR>");
                    out.println("                <TD COLSPAN=\"5\">");
                    out.println("                    <TABLE style=\"font-size:11;font-family:sans-serif;\">");
                    out.println("                        <TR>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\"><H3>Parents of this child</H3></TD>");
                    out.println("                            <TD>&nbsp</TD>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\"><H3>Available parents</H3></TD>");
                    out.println("                        </TR>");
                    out.println("                        <TR>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\">");
                    out.println("                              <SELECT NAME=\"assignedParentList\" MULTIPLE=\"YES\" SIZE=\"4\" STYLE=\"WIDTH:250PX\"");
                    out.println("</TD>");
                    out.println("                            <TD>&nbsp;&nbsp;<INPUT TYPE=\"BUTTON\" VALUE=\"<--\" onClick='selectAvailableParent()'>&nbsp;&nbsp;<BR>");
                    out.println("                                &nbsp;<BR>");
                    out.println("                                &nbsp;&nbsp;<INPUT TYPE=\"BUTTON\" VALUE=\"-->\" onClick='unselectAssignedParent()'>&nbsp;&nbsp;</TD>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\">");
                    out.println("                              <SELECT NAME=\"availableParentList\" MULTIPLE=\"YES\" SIZE=\"4\" STYLE=\"WIDTH:250PX\"");
                    out.println("        ");
                    out.println("                            </TD>");
                    out.println("                        </TR>");
                    out.println("                    </TABLE>");
                    out.println("                </TD>");
                    out.println("            </TR>");
                    out.println("            <TR>");
                    out.println("                <TD COLSPAN=\"5\">");
                    out.println("                    <TABLE style=\"font-size:11;font-family:sans-serif;\">");
                    out.println("                        <TR>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\"><H3>Selected Classes</H3></TD>");
                    out.println("                            <TD>&nbsp</TD>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\"><H3>Available Classes</H3></TD>");
                    out.println("                        </TR>");
                    out.println("                        <TR>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\">");
                    out.println("                              <SELECT NAME=\"assignedClassList\" MULTIPLE=\"YES\" SIZE=\"4\" STYLE=\"WIDTH:250PX\"");
                    out.println("</TD>");
                    out.println("                            <TD>&nbsp;&nbsp;<INPUT TYPE=\"BUTTON\" VALUE=\"<--\" onClick='selectAvailableClass()'>&nbsp;&nbsp;<BR>");
                    out.println("                                &nbsp;<BR>");
                    out.println("                                &nbsp;&nbsp;<INPUT TYPE=\"BUTTON\" VALUE=\"-->\" onClick='unselectAssignedClass()'>&nbsp;&nbsp;</TD>");
                    out.println("                            <TD ALIGN=\"CENTER\" COLSPAN=\"2\">");
                    out.println("                              <SELECT NAME=\"availableClassList\" MULTIPLE=\"YES\" SIZE=\"4\" STYLE=\"WIDTH:250PX\"");
                    out.println("        ");
                    out.println("                            </TD>");
                    out.println("                        </TR>");
                    out.println("                    </TABLE>");
                    out.println("                </TD>");
                    out.println("            </TR>");
                  }
                %>

            <TR>
                <TD COLSPAN=2>&nbsp;</TD>
                <TD COLSPAN=2>&nbsp;</TD>
            </TR>

            <TR>
                <%
                    if (editStatus.equals(FormFields.EDIT) || editStatus.equals(FormFields.NEW)) {
                        out.println("                <TD><INPUT NAME=\"" + FormFields.SAVESTUDENT + "\" TYPE=\"BUTTON\" VALUE=\"Save\" onClick=\"postProcessing('Save')\"></TD>");
                        out.println("                <TD><INPUT NAME=\"cancel\" TYPE=\"BUTTON\" VALUE=\"Cancel\" onClick='cancelForm()'></TD>");
                    }
                %>
            </TR>

        </TABLE>

    </FORM>
</HTML>

